/*
 *  Copyright (C) 2011 Hatsites
 *
 *  This program is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU General Public License
 *  as published by the Free Software Foundation; either version 2
 *  of the License, or (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 */

package org.myorg.ctm.etk.gui.swg.display.create.item.panel;

import javax.swing.ButtonGroup;
import javax.swing.JRadioButton;
import javax.swing.LayoutStyle;
import org.myorg.shr.gui.swg.display.labelized.LbzDateChooserHrz;
import org.myorg.shr.gui.swg.display.panel.PnlAbs;

/**
 *
 * @author Hatsites
 *
 * email: Hatsites_AT_gmail.com
 * ... please remove "_AT_" from the above string to get the right email address
 */

public class PnlIdtAnmSexDat extends PnlAbs{
    public PnlIdtAnmSexDat()
    {
        this._bgr_ = new ButtonGroup();
        this._rbnFemale_ = new JRadioButton();
        this._rbnMale_ = new JRadioButton();
        this._dateChooserBirth_ = new LbzDateChooserHrz("Né le", 10);
        this._dateChooserDeath_ = new LbzDateChooserHrz("Mort le", 10);
    }

    public boolean init() {
        if(!this._dateChooserBirth_.init()){
            return false;
        }
        if(!this._dateChooserDeath_.init()){
            return false;
        }

        this._dateChooserDeath_.setVisible(true);
        this._rbnFemale_.setText("Femelle");
        this._rbnMale_.setText("Male");
        this._bgr_.add(this._rbnFemale_);
        this._bgr_.add(this._rbnMale_);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(this._dateChooserBirth_)
                .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(this._dateChooserDeath_, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(20, 20, 20)
                .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(this._rbnMale_)
                .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(this._rbnFemale_)
            )
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()

                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(this._dateChooserBirth_)
                    .addComponent(this._dateChooserDeath_)
                    .addComponent(this._rbnMale_)
                    .addComponent(this._rbnFemale_)))
        );
        return true;
    }
    public void destroy() {
        return;
    }

    public String getDateNaissance() {
        return this._dateChooserBirth_.getDate();
    }
    public String getDateMort() {
        return this._dateChooserBirth_.getDate();
    }

    public String getSexe() {
         if (this._rbnFemale_.isSelected()) {
             return "f";
         }
         else if (this._rbnMale_.isSelected()) {
             return "h";
         }
         else {
             return "u";
         }
    }

    private ButtonGroup _bgr_;
    private JRadioButton _rbnFemale_;
    private JRadioButton _rbnMale_;
    private LbzDateChooserHrz _dateChooserBirth_;
    private LbzDateChooserHrz _dateChooserDeath_;

}
